import { Component, OnInit } from '@angular/core';
import {CollectServiceSvr} from '../../services/CollectServiceSvr'
import {Router,NavigationExtras} from '@angular/router'

@Component({
  selector: 'app-collection',
  templateUrl: './collection.component.html',
  styleUrls: ['./collection.component.less']
})
export class CollectionComponent implements OnInit {

  list:any=[
    {
      title:'整租-天和城2居室1',
      other:'48m² | 5层',
      money:'2030/月',
      site:'房源距即家庙步行约458米',
      src:'../../../assets/img/home1.jpg'
    },
    {
      title:'整租-天和城2居室2',
      other:'48m² | 5层',
      money:'2030/月',
      site:'房源距即家庙步行约458米',
      src:'../../../assets/img/home1.jpg'

    },
    {
      title:'整租-天和城2居室3',
      other:'48m² | 5层',
      money:'2030/月',
      site:'房源距即家庙步行约458米',
      src:'../../../assets/img/home1.jpg'

    },
    {
      title:'整租-天和城2居室4',
      other:'48m² | 5层',
      money:'2030/月',
      site:'房源距即家庙步行约458米',
      src:'../../../assets/img/home1.jpg'

    }
    
  ]
  constructor(
    private collectServiceSvr:CollectServiceSvr,
    private router:Router,
  ) { }

  // 收藏房屋列表参数
  collectionHouse:any
    // 用户id
  customerId:any=localStorage.getItem('customerId')

  ngOnInit(): void {
    this.customerId=this.customerId.replace("\"","").replace("\"","");
    this.collectServiceSvr.listCollection('',this.customerId).then((res)=>{
      // console.log(res);
      this.collectionHouse=res._Items
      console.log(this.collectionHouse);
    })
  }

  // 跳转到房屋详情页面
  gohouseDetail(e:string){
    let navigationExtras:NavigationExtras = {
      queryParams:{'key':e}
    }
    this.router.navigate(['/houseDetails'],navigationExtras)
    // console.log(e);
    
  }
}
